#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int T;
ll n,ans;
const int maxn=2e5+10;
int a[maxn];
bool vis[maxn];
ll js()
{
    ll  res=0;
    for(int i=1;i<=n;i++)
    {
        bool f=vis[i];
        int id=0;
        for(int j=i-1;j>=1;j--)
        {
            if(f==vis[j])
            {
                id=j;
                break;
            }
        }
        if(a[i]==a[id])
        {
            //cout<<i<<" "<<id<<endl;
            res+=a[id];
        }
    }
   // for(int i=1;i<=3;i++)
    //{
     //   cout<<vis[i]<<" ";
    //}
    //cout<<endl<<res<<endl;
    return res;
}
void dfs(int h)
{
    if(h==n+1)
    {
        ans=max(ans,js());
        return;
    }
    vis[h]=1;
    dfs(h+1);
    vis[h]=0;
    dfs(h+1);
    return;
}
int main ()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>T;
    while(T--)
    {
        memset(vis,0,sizeof(vis));
        ans=0;
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
        }
        dfs(1);
        cout<<ans<<'\n';
    }

    return 0;
}
/*
JS-S01359
CSP-S 2024 Diary
*/
